<#include "../common/header.htm">
<div class="content-wrapper">
	<section class="content-header">
		<ol class="breadcrumb">
			<li><a href="${ctx}/">首页</a></li>
			<li class="active"><a href="${ctx}${url!}">${title!}</a></li>
			<li class="active"><a href="#">工单详情</a></li>
		</ol>
		<#if workFormRecord.state == 200 && url?? && (url == "/workformlist/noreceive" || url == "/workformlist/nodeal")  >
 			<a href="javascript:void(0)" class="btn-commit" onclick="workForm.todeal('${workform.id}','${workFormRecord.id}','${currentDealTag}','${workform.title}')">处理</a>
		</#if>
		<#if workFormRecord.state == 100 && url?? && (url == "/workformlist/noreceive" || url == "/workformlist/nodeal") >
			<a href="javascript:void(0)" class="btn-commit" onclick="workForm.toreceive('${workform.id}', '${workFormRecord.id}','${workform.title!}')">接收</a>
		</#if>
		<a class="btn-return" href="javascript:history.back(-1);">返回</a>
	</section>
	<section class="content">
		<!-- 工单进度图 -->
		<ul class="detail-step-box">
           <li class=" <#if workFormTagSet?seq_contains(1) && workform.state!=300>current</#if>">
		      <span class="name">提交</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(2) && workform.state!=300>current</#if>">
		      <span class="name">确认</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(11) && workform.state!=300>current</#if>">
		      <span class="name">审核</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(3) && workform.state!=300>current</#if>">
		      <span class="name">开户</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(4) && workform.state!=300>current</#if>">
		      <span class="name">话术</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(5) && workform.state!=300>current</#if>">
		      <span class="name">录音</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(12) && workform.state!=300>current</#if>">
		      <span class="name">剪辑</span>
		      <span class="link"></span>
	       </li>
	       <#-- 废弃的节点，还没有直过这个节点的就不再显示了 -->
	       <#if workFormTagSet?seq_contains(6)>
	       <li class="<#if workFormTagSet?seq_contains(6) && workform.state!=300>current</#if>">
		      <span class="name">上线</span>
		      <span class="link"></span>
	       </li>
	       </#if>
	       <li class="<#if workFormTagSet?seq_contains(7) && workform.state!=300>current</#if>">
		      <span class="name">线路</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(8) && workform.state!=300>current</#if>">
		      <span class="name">验收</span>
		      <span class="link"></span>
	       </li>
	       <li class="<#if workFormTagSet?seq_contains(9) && workform.state!=300>current</#if>">
		      <span class="name">结束</span>
	       </li>
		</ul>
		
		<!-- 工单基本信息 -->
		<div class="detail-info-box">
	        <h4>基本信息：</h4>
			<div class="form-group form-inline">
			    <div class="col-sm-6">
					<label class="input_text">标题：</label> 
					<span class="info">${workform.title!}</span>
				</div>
				<div class="col-sm-6">
					<label class="input_text">编号：</label> 
					<span class="info">${workform.workFormNo!}</span>
				</div> 
			</div>
			<div class="form-group form-inline">
			    <div class="col-sm-6">
					<label class="input_text">类型：</label> 
					<span class="info">${businessTypeMap["${workform.businessType}"]!}</span>
				</div>
				<div class="col-sm-6">
					<label class="input_text">进度：</label> 
					<span class="info">${tagMap["${workFormRecord.tag}"]!}</span>
				</div> 
			</div>
			<div class="form-group form-inline">
			    <div class="col-sm-6">
					<label class="input_text">提交人：</label>
					<span class="info">${workform.submiterName!}</span> 
				</div>
				<div class="col-sm-6">
					<label class="input_text">提交时间：</label>
					<span class="info">${workform.createrTime!}</span>
				</div> 
			</div>
			<div class="form-group form-inline">
			    <div class="col-sm-6">
					<label class="input_text">计费：</label>
					<span class="info">
						<#if workform.clearingForm?? && clearingFormMap["${workform.clearingForm}"]??>${clearingFormMap["${workform.clearingForm}"]!}</#if>
					</span> 
				</div>
				<div class="col-sm-6">
					<label class="input_text">期限（月）：</label>
					<span class="info">${workform.clearingFormMonths!"--"}</span>
				</div> 
			</div>
			<div class="form-group form-inline">
				<div class="col-sm-6">
					<label class="input_text">线路：</label>
					<span class="info">${workform.lineNum!}</span>
				</div> 
			    <div class="col-sm-6">
					<label class="input_text">并发：</label> 
					<span class="info">${workform.concurrentNum!}</span>
				</div>
			</div>
			<div class="form-group form-inline">
				<div class="col-sm-6">
					<label class="input_text">当前经办人：</label> 
					<span class="info"><@mymacro.firstNotEmpty workFormRecord.receiverName! workFormRecord.receiverGroupName!></@mymacro.firstNotEmpty></span>
				</div>
			    <div class="col-sm-6">
					<label class="input_text">客户经理：</label>
					<span class="info">${workform.customerManager!}</span>
				</div>
			</div>
			<div class="form-group form-inline">
				<div class="col-sm-12">
					<label class="input_text">参与人：</label> 
					<span class="info" title="${participantNames!}">
						${participantNames!}
					</span>
				</div>
			</div> 
			<div class="form-group form-inline">
				<div class="col-sm-12">
					<label class="input_text">备注：</label>
					<span class="info" title="${workform.remark!}">${workform.remark!}</span> 
				</div>
			</div>
			<div class="form-group form-inline special">
				<div class="col-sm-12">
					<label class="input_text">附件：</label>
					<#list attachFile as map>
			        	<a href="javascript:void(0)" class="info" onclick="workForm.download('${map['fileUrl']!}')">${map['fileName']!}</a> 
					</#list>
				</div>
			</div>
		</div>
		
		<!-- 处理流程 -->
		<div class="detail-process-wrapper">
			<div class="title-box">
				<span>处理流程</span>
			</div>
			<!--end .title-box-->
			<ul class="detail-process-box">
				<#list recordsmap as map>
					<li class="current-step">
						<div class="title">
							<span class="bold" style="float: left;">${tagMap["${map['tag']!}"]!}</span>
							<span class="time">${map['time']!}</span>
							<span class="name">${map['state']!}</span>
							<span class="record_state"><@mymacro.firstNotEmpty map['dealUser']! map['dealGroup']!></@mymacro.firstNotEmpty></span>
							
							<!-- 评论按钮 -->
							<a class="comment" href="javascript:void(0)" onclick="workForm.comment(${map['workFormRecordId']!},${workform.id!},${workFormRecord.id!},'${title!}')">评论</a>
						</div>
						<!-- 备注 -->
						<#list map?keys as itemKey>
							 <#if itemKey="remark">
							     <#if map[itemKey]??>
							       <div class="txt-box">备注：${map[itemKey]!}</div>
							     </#if>
			                 </#if>
		                </#list>
						<!-- 附件 -->
		                <#if (map.attachs)??&&(map.attachs?size>0)>
		                	<div class="doct-box">
		                		<div class="title">附件：</div>
					         	<span class="record_attach">
							        <#list map.attachs as a>
							        	<a  href="${a.fileUrl}">${a.fileName}&nbsp;&nbsp;<i class="fa fa-download"></i></a>
							    	</#list>
						        </span>
					        </div>
				        </#if>
						<!-- 评论内容 -->
		                <#list map?keys as itemKey>
		                   <#if itemKey="commentList">
			                    <#if map[itemKey]?exists>  
					                <#list map[itemKey] as comment>   
					                   <div class="comment-info-box">
					                	   <p class="info">评论内容：${comment.content!}</p>
					                	   <span class="time txt-gray">${comment.commentTime!}</span>
					                	   <span class="txt-gray">评论人：${comment.commentUserName!}</span>
					                  </div>  
					                </#list>  
					            </#if> 
		                    </#if>
		                </#list>
						<!-- end each -->
					</li>
				</#list>
				<!-- end loop -->
			</ul>
		</div>
	</section>
</div>

<script type="text/javascript">
/* 标点 */
var lastLightIndex = -1;
var $lis = $(".detail-step-box li");
for (var i = 0; i < $lis.length; i++) {
	var $currli = $lis.eq($lis.length - 1 - i);
	if ( lastLightIndex == -1 && $currli.hasClass("current") ) {
		lastLightIndex = $lis.length - 1 - i;
	}
	if (($lis.length - 1 - i) <= lastLightIndex) {
		$currli.addClass("current");
	}
}

var is_submit=false;
var workForm = {
	comment : function(workFormRecordId, workFormId, deatilWorkRecordId, headTitle) {
		if(is_submit){
			return;
		}
		is_submit=true;
		var title ="评论";
		var j = 0;
		base.getView({
			url:"${ctx}/workform/tocomment?workFormRecordId="+workFormRecordId+"&workFormId="+workFormId+"&deatilWorkRecordId="+deatilWorkRecordId+"&headTitle="+headTitle,
			success:function(result){
				bootbox.dialog({
					title:title,
					message:result,
					size:"large",
					closeButton : false,
					buttons:{
						cancel:{
							label:"取消",
							className:"btn btn-secondary",
							callback:function() {
								is_submit=false;
							}
						},
						sure:{
							label:"确定",
							className:"btn btn-primary",
							callback:function(){
								if (j != 0) {
									is_submit=false;
									return ;
								}
								j++;
								var $dialogObj = $("#comment");
								if ($dialogObj.valid()) {
									$dialogObj.submit();
								} else {
									j = 0;
								}
								return false;
							}
						}
					}
				})
			}
		})
	},
	toreceive : function(workFormId, workFormRecordId, workName) {
		if(is_submit){
			return;
		}
		is_submit=true;
		var title ="接收工单";
		var j = 0;
		base.getView({
			url:"${ctx}/workform/toreceive?workFormId="+workFormId+"&workFormRecordId="+workFormRecordId+"&workName="+workName,
			success:function(result){
				bootbox.dialog({
					title:title,
					message:result,
					size:"large",
					closeButton : false,
					buttons:{
						cancel:{
							label:"取消",
							className:"btn btn-secondary",
							callback:function() {
								is_submit=false;
							}
						},
						sure:{
							label:"确定",
							className:"btn btn-primary",
							callback:function(){
								if (j != 0) {
									is_submit=false;
									return ;
								}
								j++;
								var $dialogObj = $("#receive");
								if ($dialogObj.valid()) {
									$dialogObj.submit();
								} else {
									j = 0;
								}
								return false;
							}
						}
					}
				})
			}
		})
	},
	todeal : function(id, workFormRecordId, currentDealTag, workName) {
		if(is_submit){
			return;
		}
		is_submit=true;
		var title ="工单处理";
		var j = 0;
		base.getView({
			url:"${ctx}/workform/tohandle?workFormId="+id+"&lastRecordId="+workFormRecordId+"&currentDealTag="+currentDealTag+"&workName="+workName,
			success:function(result){
				bootbox.dialog({
					title:title,
					message:result,
					size:"large",
					closeButton : false,
					buttons:{
						cancel:{
							label:"取消",
							className:"btn btn-secondary",
							callback:function() {
								is_submit=false;
							}
						},
						sure:{
							label:"确定",
							className:"btn btn-primary",
							callback:function(){
								if (j != 0) {
									is_submit=false;
									return ;
								}
								j++;
								var $dialogObj = $("#handle");
								if ($dialogObj.valid()) {
									$dialogObj.submit();
								} else {
									j = 0;
								}
								return false;
							}
						}
					}
				})
			}
		})
	},
	//a 标签下载
	download:function(url) {
		window.location.href = "${ctx}"+encodeURI(url);
	}
}
</script>
<#include "../common/footer.htm">
